﻿@page
@using Volo.Abp.AspNetCore.Mvc.UI.Layout
@model YaAppoint.Web.Pages.DeviceTypes.IndexModel
@inject IPageLayout PageLayout
@{
    PageLayout.Content.Title = "设备类型";
}
@section scripts
{
    <abp-script src="/Pages/DeviceTypes/Index.cshtml.js"></abp-script>
}

<div class="content-container">
    <div id="app">
        <el-row>
            <el-col :span="23">
                <div class="grid-content bg-purple-dark">
                    <el-button v-on:click="showCreate" icon="el-icon-plus" size="mini" v-if="createPermission">新建</el-button>
                    <el-input v-model.trim="filterName" placeholder="用户名" size="mini" style="width:300px;margin-left:10px" clearable></el-input>
                    <el-button type="primary" v-on:click="loadTableData" icon="el-icon-search" size="mini" style="margin-left:10px;">搜索</el-button>
                    <el-button v-on:click="deleteMany" icon="el-icon-delete" size="mini" :disabled="!selectedDeviceTypes || selectedDeviceTypes.length===0">删除</el-button>
                </div>
            </el-col>
            <el-col :span="1">
                <div class="grid-content bg-purple-dark">
                    <el-button v-on:click="loadTableData" icon="el-icon-refresh" size="mini"></el-button>
                </div>
            </el-col>
        </el-row>
        <hr class="line-gray" />
        <div class="container-body">
            <div class="table-container">
                <el-table :data="tableData" height="500" class="el-table" ref="deviceTypeTable" size="mini" v-on:selection-change="selectionChange">
                    <el-table-column type="selection" >
                    </el-table-column>
                    <el-table-column type="index"  label="编号">

                    </el-table-column>
                    <el-table-column label="名称" width="200"  property="name">

                    </el-table-column>
                    <el-table-column label="编码" width="100" property="outerCode">

                    </el-table-column>
                    <el-table-column label="模态设备" width="150"  property="modality">

                    </el-table-column>
                    <el-table-column label="活动" property="type">
                        <template slot-scope="scope">
                            <el-switch v-model="scope.row.isActive"
                                       disabled>
                            </el-switch>
                        </template>
                    </el-table-column>
                    <el-table-column label="操作" width="150" property="type">
                        <template slot-scope="scope">
                            <el-button size="mini" icon="el-icon-edit" v-if="editPermission" v-on:click="showEdit(scope.$index, scope.row)"></el-button>
                            <el-button size="mini" icon="el-icon-delete" type="danger" v-on:click="deleteDeviceType(scope.row.id)" v-if="deletePermission"></el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </div>
        </div>

        <!-- 创建新用户-->
        <el-dialog :title="dialogTitle" :visible.sync="dialogVisible" width="600px" v-on:close="resetForm" :close-on-click-modal="false">
            <el-form :model="deviceType" :label-width="formLabelWidth" ref="deviceTypeForm" :rules="rules">
                <el-row>
                    <el-col :span="24">
                        <div class="grid-content bg-purple-dark" >
                            <el-form-item label="名称" prop="name">
                                <el-input v-model.trim="deviceType.name" size="mini" autocomplete="off" clearable></el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <div class="grid-content bg-purple-dark">
                            <el-form-item label="编码" prop="outerCode">
                                <el-input v-model.trim="deviceType.outerCode" v-on:change="onOuterCodeChange" size="mini" autocomplete="off" clearable></el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <div class="grid-content bg-purple-dark">
                            <el-form-item label="模态设备">
                                <el-input v-model.trim="deviceType.modality" size="mini" autocomplete="off" clearable></el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
                <el-row>
                    <el-col :span="24">
                        <div class="grid-content bg-purple-dark">
                            <el-form-item label="活动">
                                <el-switch v-model="deviceType.isActive">
                                </el-switch>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" v-on:click="save" size="mini">保存</el-button>
                <el-button v-on:click="resetForm" size="mini">取 消</el-button>
            </div>
        </el-dialog>
    </div>
</div>